home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / xinvaders / vaders.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  4.6 KB  |  227 lines

  1. /* 
  2. Copyright notice:
  3.  
  4. This is mine.  I'm only letting you use it.  Period.  Feel free to rip off
  5. any of the code you see fit, but have the courtesy to give me credit.
  6. Otherwise great hairy beasties will rip your eyes out and eat your flesh
  7. when you least expect it.
  8.  
  9. Jonny Goldman <jonathan@think.com>
  10.  
  11. Wed May  8 1991
  12. */
  13.  
  14. /* vaders.h - definitions of vaders data structures. */
  15.  
  16. #ifndef _vaders_h
  17. #define _vaders_h
  18.  
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <X11/Xlib.h>
  22. #include <X11/Xos.h>
  23.  
  24. /* #include <X11/Xutil.h> */
  25. #include <X11/cursorfont.h>
  26.  
  27. #include <X11/IntrinsicP.h>
  28. #include <X11/StringDefs.h>
  29.  
  30. #include <X11/Xaw/Command.h>
  31.  
  32. #ifndef XtRFloat
  33. #define XtRFloat "Float"
  34. #endif
  35.  
  36. #define rint(x) ((int) (x))
  37. #define MIN(x, y)    ((x) < (y) ? (x) : (y))
  38. #define MAX(x, y)    ((x) > (y) ? (x) : (y))
  39.  
  40. #define VWIDTH         240
  41. #define IWIDTH         75
  42. #define VHEIGHT     190
  43.  
  44. #ifndef M_PI
  45. #define    M_PI    3.14159265358979323846
  46. #define    M_PI_2    1.57079632679489661923
  47. #define    M_PI_4    0.78539816339744830962
  48. #endif
  49.  
  50. #ifdef MAIN
  51. #define ext
  52. #else
  53. #define ext extern
  54. #endif
  55.  
  56. /*
  57.  * Definitions to make us act as a widget.
  58.  */
  59.  
  60. /* New fields for the Vaders widget class record */
  61. typedef struct {
  62.      int mumble;   /* No new procedures */
  63. } VadersClassPart;
  64.  
  65. /* Full class record declaration */
  66. typedef struct _VadersClassRec {
  67.     CoreClassPart       core_class;
  68.     VadersClassPart    vaders_class;
  69. } VadersClassRec;
  70.  
  71. extern VadersClassRec vadersClassRec;
  72. extern WidgetClass vadersWidgetClass;
  73.  
  74. /* New fields for the Vaders widget record */
  75. typedef struct _VadersPart {
  76.     int dummy;
  77. } VadersPart;
  78.  
  79.  
  80.  
  81. /* Full instance record declaration */
  82.  
  83. typedef struct _VadersRec {
  84.     CorePart core;
  85.     VadersPart vaders;
  86. } VadersRec, *VadersWidget;
  87.  
  88.  
  89.  
  90.  
  91. /*
  92.  * Actual vaders definitions.
  93.  */
  94.  
  95. ext Widget pausebutton, infobutton;
  96. ext int scale;
  97.  
  98. ext Boolean debug;
  99. ext int level;
  100.  
  101. ext Display *dpy;
  102. ext Window gamewindow, labelwindow;
  103. ext VadersWidget gamewidget, labelwidget;
  104. ext int gamewidth, gameheight;
  105. ext Widget toplevel;
  106. ext int score;
  107. ext int basesleft;
  108.  
  109. /* Base info: */
  110.  
  111. ext int basewait;        /* Number of milleseconds to wait between */
  112.                 /* moving base. */
  113.  
  114. ext XtIntervalId basetimerid;
  115.  
  116. ext Pixel basepixel;
  117. ext Pixel buildingpixel;
  118. ext Boolean basedestroyed;    /* TRUE if the base is non-existant */
  119.  
  120. /* Vader info: */
  121.  
  122. ext XtIntervalId vadertimerid;
  123. ext Pixel vader1pixel;
  124. ext Pixel vader2pixel;
  125. ext Pixel vader3pixel;
  126. ext int vaderwait;        /* Number of milleseconds to wait between */
  127.                 /* moving vaders. */
  128.  
  129. /* Spacer info */
  130.  
  131. ext Pixel spacerpixel;
  132. ext XtIntervalId spacertimerid;
  133. ext int spacerwait;        /* Number of milliseconds to wait between
  134.                 /* moving spacers. /*
  135. ext int spacerappear;        /* same, but for the interval between appearances */
  136.  
  137. ext Boolean spacer_shown;        /* Currnet_Spacer is something */
  138. ext int spacer_counter;        /* number of cycles to create a spacer */
  139.  
  140. /* Shot info. */
  141.  
  142. ext XtIntervalId shottimerid;
  143. ext XtIntervalId vshottimerid;
  144. ext Pixel shotpixel;
  145. ext Pixel vshotpixel;
  146. ext int shotwait;
  147. ext int vshotwait;
  148. ext int maxshots;        /* How many shots are allowed to exist at */
  149.                 /* once. */
  150. ext int maxvshots;        /* How many shots are allowed to exist at */
  151.                 /* once. */
  152. ext int numshots;        /* how many shots (from the base) there are right now. */
  153. ext int numvshots;        /* how many shots (from vaders) there are right now. */
  154.  
  155. /* Score info */
  156.  
  157. ext Pixel scorepixel;
  158.  
  159.  
  160. ext int bases, nextbonus, hiscore, lastscore;
  161.  
  162.  
  163. ext GC
  164.   foregc, backgc, basegc, buildinggc, vadergc[3],
  165.   shotgc, vshotgc, spacergc, scoregc;
  166.  
  167. ext XImage *me_image;
  168.  
  169. /* From widget.c */
  170.  
  171. extern Boolean TakeFocus();
  172. extern void Quit();
  173. extern void Pause();
  174. extern int paused;
  175. extern void SuspendTimers();
  176. extern void EnableTimers();
  177. extern void ShowInfo();
  178.  
  179. /* From base.c */
  180.  
  181. extern void MoveBase();
  182. extern void MoveLeft();
  183. extern void MoveRight();
  184. extern void Stop();
  185. extern void Fire();
  186. extern Boolean ShotHitsBase();
  187. extern Boolean ShotHitsBuilding();
  188. extern void InitBase();
  189. extern void PaintBase();
  190. extern void DrawBuildings();
  191.  
  192. /* From vaders.c */
  193.  
  194. extern Boolean ShotHitsVader();
  195. extern void MoveVaders();
  196. extern void InitVaders();
  197. extern void AddVShot();
  198. extern void MoveVShots();
  199. extern void CreateVaders();
  200. extern void PaintAllVaders();
  201.  
  202. /* from spacer.c */
  203.  
  204. extern Boolean ShotHitsSpacer();
  205. extern void MoveSpacer();
  206. extern void MakeSpacer();
  207. extern void InitSpacers();
  208. extern void PaintSpacer();
  209.  
  210. /* From shot.c */
  211.  
  212. extern void AddLine();
  213. extern void AddShot();
  214. extern void AddVshot();
  215. extern void MoveShots();
  216. extern void MoveVshots();
  217. extern void PaintAllShots();
  218. ext Pixel defaultfore, defaultback;
  219.  
  220. ext char *vaderfont;
  221.  
  222. #ifdef SYSV
  223. # define random  lrand48
  224. # define srandom(seed)  srand48(((long)(seed)))
  225. #endif /*SYSV*/
  226. #endif _vaders_h
  227.